package mushystuff.dtb.web.vo;

import java.util.ArrayList;
import java.util.Collection;

import mushystuff.dtb.core.model.UserStory;

public class UserStoryVO {
    
    private long id;
    
    private String story;
    
    private double estimate;
    
    private String priority;
    
    public UserStoryVO() {
        
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getStory() {
        return story;
    }

    public void setStory(String story) {
        this.story = story;
    }

    public double getEstimate() {
        return estimate;
    }

    public void setEstimate(double estimate) {
        this.estimate = estimate;
    }

    public String getPriority() {
        return priority;
    }

    public void setPriority(String priority) {
        this.priority = priority;
    }

    public static UserStoryVO[] convert(Collection<UserStory> userStories) {
        Collection<UserStoryVO> res = new ArrayList<UserStoryVO>();
        for (UserStory userStory : userStories) {
            UserStoryVO vo = new UserStoryVO();
            vo.setId(userStory.getId());
            vo.setStory(userStory.getStory());
            vo.setEstimate(userStory.getEstimate().getStoryPoints());
            vo.setPriority(userStory.getPriority().name());
            res.add(vo);
        }
        UserStoryVO[] resArray = new UserStoryVO[res.size()];
        resArray = res.toArray(resArray);
        return resArray;
    }

}
